<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <ul>
      <li v-for="v in list" :key="v.id">
        {{ v.num }} <button @click="del(v.id)">删除</button>
      </li>
    </ul>
    <button @click="gen">生成</button>
  </div>
  
  <script src="https://unpkg.com/vue@2.7.14/dist/vue.js"></script>
  <script>
    new Vue({
      el: '#app',
      data: {
        list: [
          // { id: 1, num: 15 },
          // { id: 2, num: 13 }
        ]
      },
      methods: {
        del(id) {
          this.list = this.list.filter(v => v.id !== id)
        },
        gen() {
          const nextId = Math.max(0, ...this.list.map(v => v.id)) + 1

          // Math.random() // [0~1) 
          // Math.random() * 21 // [0~21)
          const num = Math.floor(Math.random() * 21) // [0~20]
          
          const obj = { id: nextId, num }

          this.list.unshift(obj)

        }
      }
    })
  </script>
</body>
</html>